<template>
  <div>
    <div style="margin:15px 0;">
      <span style="font-size:35px;font-weight:600;">客户的留言信息</span>
    </div>
    <div>
      <el-table :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase())
        || data.content.toLowerCase().includes(search.toLowerCase())
        || data.company.toLowerCase().includes(search.toLowerCase())
        || data.telephone.toLowerCase().includes(search.toLowerCase())
        || data.email.toLowerCase().includes(search.toLowerCase())
        )" style="width: 100%">
        <el-table-column label="日期" prop="updateTime">
        </el-table-column>
        <el-table-column label="姓名" prop="name">
        </el-table-column>
        <el-table-column label="公司" prop="company">
        </el-table-column>
        <el-table-column label="手机" prop="telephone">
        </el-table-column>
        <el-table-column label="邮箱" prop="email">
        </el-table-column>
        <el-table-column label="留言" prop="content">
        </el-table-column>
        <el-table-column align="right">
          <template slot="header" slot-scope="scope">
            <el-input v-model="search" size="mini" placeholder="输入关键字搜索" />
          </template>
          <template slot-scope="scope">
            <el-button size="small" disabled @click="handleEdit(scope.$index, scope.row)">查看</el-button>
            <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Message',
  data () {
    return {
      tableData: [],
      search: ''
    }
  },
  methods: {
    handleEdit (index, row) {
      console.log(index, row)
    },
    handleDelete (index, row) {
      console.log(index, row)
    },
    getData () {
      this.$axios({
        method: 'get',
        url: '/words/select'
      }).then((res) => {
        this.tableData = res.data.data
      })
    }
  },
  mounted () {
    this.getData()
  }
}
</script>

<style scoped>
</style>
